package com.example.lib_activity;

import com.drouter.api.core.DRouter;
import com.drouter.api.interceptor.ActionInterceptor;
import com.drouter.api.thread.ActionPost;
import com.drouter.base.annotation.Interceptor;

/**
 * Created by hcDarren on 2018/1/28.
 */
@Interceptor(priority = 12)
public class ActiveLoginInterceptor implements ActionInterceptor {
    @Override
    public void intercept(ActionChain chain) {
        ActionPost actionPost = chain.action();
        if(chain.actionPath().equals("libactivity/active")) { // 要跳转到活动。统一处理。
            // 跳转登录页面,埋点，转发到别的页面。网络判断，添加额外参数等。
            DRouter.getInstance().action("libpersonal/login")
                    .context(actionPost.context)
                    .invokeAction();
            // 拦截：不会再往下分发了
            chain.onInterrupt();
        }
        chain.proceed(actionPost); // 继续往下分发。
    }
}
